function onNewMultiLanguage(frmID, msgDiv, langtable)
{
		
	var newId = '';
	$(frmID).request(
		{
			asynchronous: false,
			parameters: $(frmID).serialize(true),
	  		onComplete: function(transport)
	  		{ 
			  	var response = transport.responseText || "";
				var pos=response.indexOf('<!');
				content=response.substring(0,pos);
		    	
		    	$(msgDiv).innerHTML = '';
		    	//alert(content);
		    	if(content != "")
		    	{
		    		obj = content.evalJSON();
		    		
		    		
		    		if(obj == null)
		    		{
		    			$(msgDiv).update('Something wrong! Reponsed string is: ' + response);
		    		}
		    		
				    	$(msgDiv).update(obj.message);
				    
				   if(obj.ID==1)
				   {
					    if(langtable != null && $(langtable) != null)
					    {
							sClassName = 'newrow';
						
						    	//repair new row used to add to table
							    str = '<tr class="' + sClassName + '">';
								str += '<td align="left">' + obj.multilanguage + '</td>';
								str += '<td align="left">' + obj.english + '</td>';
								str += '<td align="left">' + obj.german + '</td>';
								str += '<td align="left">' + obj.french + '</td>';
								str += '<td><a href="?module=BgcmsMultiLanguage&sub=edit_lang&id=' + obj.multilanguage + '" class="edit">Edit</a></td>';
								str += '<td><a href="javascript::void();" onclick="onDeleteMultiLanguage(\'' + 
								$(frmID).action + '\',\'' + obj.multilanguage + '\')" class="delete">Delete</a></td>';
								str += '</tr>';
								
								$(langtable).innerHTML += str;
								
								newId = 'cat-' + obj.ID;
					    }
				   }
		    	}
	  		}
		});

	$(msgDiv).style.display = 'block';
	Fat.fade_element(msgDiv, null, 1500, null, null);
	if(newId != '')
	{
		Fat.fade_element(newId);
		$(frmID).reset();
	}
	//revent submit page
	return false;
}

function onDeleteMultiLanguage(url, catId, cbo)
{
	var isOK = -1;
	
	if(!confirm('Are you sure you want to delete the multilanguage with Key Language:' + catId))
	{
		return false;
	}
	
	new Ajax.Request(url, 
	{
	  method: 'post',
	  asynchronous: false,
	  parameters:'act=removelang&lang=' + catId,
	  onSuccess: function(transport) 
  		{
			var response = transport.responseText || "";
				var pos=response.indexOf('<!');
				content=response.substring(0,pos);
			
			//alert(response);
			
			obj = content.evalJSON();

    		if(obj == null)
    		{
    			$('ajaxResponse1').innerHTML = 'Something wrong! Reponsed string is: ' + response;
    		}
		
    		$('ajaxResponse1').update(obj.message);
		}
	});

	$('ajaxResponse1').style.display = 'block';
	Fat.fade_element('ajaxResponse1', null, 1500, null, null);
	
		rowID = 'rowlang_' + catId;
		Fat.fade_element(rowID, null, 1000, "#f22", null);
		setTimeout("$(rowID).remove()", 1000);
		
}


function onEditMultiLanguage(frmID, msgDiv,page)
{
	var newId = '';
	var status = null;
	var ret = null;
	var message = null;
	$(frmID).request(
		{
			asynchronous: false,
			parameters: $(frmID).serialize(true),
	  		onComplete: function(transport)
	  		{ 
			  	var response = transport.responseText || "";
				var pos=response.indexOf('<!');
				content=response.substring(0,pos);
				//alert(response);
		    	$(msgDiv).innerHTML = '';
		    	if(content != "")
		    	{
		    		obj = content.evalJSON();
		    		if(obj == null)
		    		{
		    			$(msgDiv).update('Something wrong! Reponsed string is: ' + response);
		    		}
		    		
			    	if(msgDiv != null)
				    	$(msgDiv).update(obj.message);
					if(obj.ID==1)
					{
						ret =1;	
						message = obj.msg;
					}
					
		    	}
	  		}
		});
	if(ret==1)
	{
		document.location = page+"&message="+message;
	}
	else
	{
		$(msgDiv).style.display = 'block';
		Fat.fade_element(msgDiv, null, 1500, null, null);
	//revent submit page
	}
	return false;
}

function onAddNewLanguage(frmID, msgDiv, langtable)
{
		
	var newId = '';
	$(frmID).request(
		{
			asynchronous: false,
			parameters: $(frmID).serialize(true),
	  		onComplete: function(transport)
	  		{ 
			  	var response = transport.responseText || "";
				var pos=response.indexOf('<!');
				content=response.substring(0,pos);
		    	
		    	$(msgDiv).innerHTML = '';
		    	//alert(response);
		    	if(content != "")
		    	{
		    		obj = content.evalJSON();
		    		
		    		
		    		if(obj == null)
		    		{
		    			$(msgDiv).update('Something wrong! Reponsed string is: ' + response);
		    		}
		    		
				    	$(msgDiv).update(obj.message);
				    
				   if(obj.ID==1) 
				   {
					    if(langtable != null && $(langtable) != null)
					    {
							sClassName = 'newrow';
							if(obj.active=='1')
								check = "x";
							
						    	//repair new row used to add to table
							    str = '<tr class="' + sClassName + '">';
								str += '<td align="left">' + obj.key_lang + '</td>';
								str += '<td align="left">' + obj.name_lang + '</td>';
								str += '<td align="center">' + obj.imgflag + '</td>';
								str += '<td align="center">' + check + '</td>';
								str += '<td><a href="?module=BgcmsMultiLanguage&tab=lang&sub=edit_lang&id=' + obj.lang_id + '" class="edit">Edit</a></td>';
								str += '<td><a href="javascript:void(0);" onclick="onDeleteLanguage(\'' + 
								$(frmID).action + '\',\'' + obj.key_lang + '\')" class="delete">Delete</a></td>';
								str += '</tr>';
								
								$(langtable).innerHTML += str;
								
					    }
				   }
		    	}
	  		}
		});

	$(msgDiv).style.display = 'block';
	Fat.fade_element(msgDiv, null, 1500, null, null);
	if(newId != '')
	{
		Fat.fade_element(newId);
		$(frmID).reset();
	}
	//revent submit page
	return false;
}

function onDeleteLanguage(url, langId, cbo)
{
	var isOK = -1;
	
	if(!confirm('Are you sure you want to delete the multilanguage with Key Language:' + langId))
	{
		return false;
	}
	
	new Ajax.Request(url, 
	{
	  method: 'post',
	  asynchronous: false,
	  parameters:'act=dellang&lang=' + langId,
	  onSuccess: function(transport) 
  		{
			var response = transport.responseText || "";
				var pos=response.indexOf('<!');
				content=response.substring(0,pos);
			
			//alert(response);
			
			obj = content.evalJSON();

    		if(obj == null)
    		{
    			$('ajaxResponse1').innerHTML = 'Something wrong! Reponsed string is: ' + response;
    		}
		
    		$('ajaxResponse1').update(obj.message);
		}
	});

	$('ajaxResponse1').style.display = 'inherit';
	Fat.fade_element('ajaxResponse1', null, 1500, null, null);
	
		rowID = 'rowlang_' + langId;
		Fat.fade_element(rowID, null, 1000, "#f22", null);
		setTimeout("$(rowID).remove()", 1000);
		
}

